﻿namespace PassiveView
{
    using System.Collections;
    using System.Windows;
    using System.Windows.Controls;

    /// <summary>
    /// more in the code behind, but no data binding
    /// </summary>
    public partial class RegistrationView : Window, IRegistrationView
    {
        private readonly RegistrationController _controller;

        public RegistrationView()
        {
            InitializeComponent();

            _controller = new RegistrationController(this, new RegistrationService());
        }

        string IRegistrationView.Email
        {
            get { return Email.Text; }
        }

        string IRegistrationView.Password
        {
            get { return Password.Text; }
        }

        string IRegistrationView.Confirm
        {
            get { return Confirm.Text; }
        }

        IList IRegistrationView.ValidationErrors
        {
            get { return ValidationSummary.Items; }
        }

        public void Enable()
        {
            RegistrationButton.IsEnabled = true;
        }

        public void Disable()
        {
            RegistrationButton.IsEnabled = false;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _controller.Register();
        }

        private void Grid_TextChanged(object sender, TextChangedEventArgs e)
        {
            _controller.ValidateForm();
        }
    }
}